package com.rmb.entity.result;
import com.google.common.collect.ImmutableMap;
import com.rmb.common.model.response.ResultCode;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;
/**
 * @author wan
 */

@ToString
public enum EngIneCode implements ResultCode {
    /**
     * 错误码
     */
    COMPILE_FAILED(false, 31001, "编译失败！"),
    THE_DATA_ENGINE_EXISTS(false,31002,"数据引擎函数存在！"),
    THIS_OBJECT_ISNULL(false,31003,"对象是否为空");

    /**
     * 操作代码
     */
    @ApiModelProperty(value = "操作是否成功", example = "true", required = true)
    boolean success;

    /**
     * 操作代码
     */
    @ApiModelProperty(value = "操作代码", example = "22001", required = true)
    int code;

    /**
     * 提示信息
     */
    @ApiModelProperty(value = "操作提示", example = "操作过于频繁！", required = true)

    String message;

    private EngIneCode(boolean success, int code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    private static final ImmutableMap<Integer, EngIneCode> CACHE;

    static {
        final ImmutableMap.Builder<Integer, EngIneCode> builder = ImmutableMap.builder();
        for (EngIneCode commonCode : values()) {
            builder.put(commonCode.code(), commonCode);
        }
        CACHE = builder.build();
    }

    @Override
    public boolean success() {
        return success;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }
}
